#!/bin/bash 
hostname=`hostname`
hostip=`cat /etc/hosts | grep ${hostname} | awk '{print $1}'`

echo "start fastdfs at "${hostip}
fdfs_trackerd /etc/fdfs/tracker.conf
sleep 1
tail -f /home/yuqing/fastdfs/logs/trackerd.log &

sed -i '/tracker_server.*=.*/d' /etc/fdfs/storage.conf
echo "tracker_server = ${hostip}" >> /etc/fdfs/storage.conf
fdfs_storaged /etc/fdfs/storage.conf
sleep 1
tail -f /home/yuqing/fastdfs/logs/storaged.log &
sed -i '/tracker_server.*=.*/d' /etc/fdfs/client.conf
echo "tracker_server = ${hostip}" >> /etc/fdfs/client.conf


echo "start nginx forceground"
sed -i '/tracker_server.*=.*/d' /etc/fdfs/mod_fastdfs.conf
echo "tracker_server = ${hostip}" >> /etc/fdfs/mod_fastdfs.conf
sed -i '/url_have_group_name.*=.*/d' /etc/fdfs/mod_fastdfs.conf
echo "url_have_group_name = true" >> /etc/fdfs/mod_fastdfs.conf

/usr/local/nginx/sbin/nginx -g 'daemon off;'
